package cn.edu.hziee;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ServletDemo1 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //通过HttpServletResponse对象设置页面响应编码格式
        response.setContentType("text/html;charset=UTF-8");
        // 得到输出流PrinterWriter对象,Servlet使用输出流来产生响应
        PrintWriter out= response.getWriter();
        //通过PrintWriter对象向页面打印信息
        out.write("实现第一个servlet程序");
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //通过HttpServletResponse对象设置页面响应编码格式
        response.setContentType("text/html;charset=UTF-8");
        // 得到输出流PrinterWriter对象,Servlet使用输出流来产生响应
        PrintWriter out= response.getWriter();
        //通过PrintWriter对象向页面打印信息
        out.write("实现第一个servlet程序");
    }
}

